package com.maila.xiaoaoschool.fragment;


import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;

import com.maila.xiaoaoschool.R;
import com.maila.xiaoaoschool.activity.NoticeActivity;
import com.maila.xiaoaoschool.activity.RecommendActivity;
import com.maila.xiaoaoschool.activity.SaleActivity;
import com.maila.xiaoaoschool.activity.ScoreActivity;
import com.maila.xiaoaoschool.activity.ShopDetailsActivity;
import com.maila.xiaoaoschool.activity.XiaoAoMallActivity;
import com.maila.xiaoaoschool.adapter.MainUAdapter;
import com.maila.xiaoaoschool.util.StartActivityUtils;
import com.maila.xiaoaoschool.widget.NoScrollGridView;
import com.maila.xiaoaoschool.widget.UPMarqueeView;
import com.zhy.autolayout.AutoLinearLayout;
import com.zhy.autolayout.AutoRelativeLayout;
import com.zhy.autolayout.utils.AutoUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/9/23.
 */

public class FindFragment extends Fragment {
    @BindView(R.id.tv_search)
    TextView tvSearch;
    @BindView(R.id.ll_search)
    AutoLinearLayout llSearch;
    @BindView(R.id.toolbar)
    AutoRelativeLayout toolbar;
    @BindView(R.id.btn_sell)
    ImageView btnSell;
    @BindView(R.id.btn_mall)
    ImageView btnMall;
    @BindView(R.id.btn_message)
    ImageView btnMessage;
    @BindView(R.id.btn_jifen)
    ImageView btnJifen;
    @BindView(R.id.btn_tuijian)
    ImageView btnTuijian;
    @BindView(R.id.iv_ad)
    ImageView ivAd;
    @BindView(R.id.laba)
    ImageView laba;
    @BindView(R.id.upview1)
    UPMarqueeView upview1;
    @BindView(R.id.gv_youxuan)
    NoScrollGridView gvYouxuan;
    @BindView(R.id.iv_art)
    ImageView ivArt;
    @BindView(R.id.tv_art_content)
    TextView tvArtContent;
    Unbinder unbinder;
    MainUAdapter mainUAdapter;
    public static FindFragment newInstance(String param1) {
        FindFragment fragment = new FindFragment();
        Bundle args = new Bundle();
        args.putString("agrs1", param1);
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_find, container, false);
        AutoUtils.autoSize(view);
        unbinder = ButterKnife.bind(this, view);
        mainUAdapter=new MainUAdapter(getActivity());
        gvYouxuan.setAdapter(mainUAdapter);
        gvYouxuan.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                StartActivityUtils.start(getActivity(), ShopDetailsActivity.class);
            }
        });
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        unbinder.unbind();
    }

    @OnClick({R.id.ll_search, R.id.btn_sell, R.id.btn_mall, R.id.btn_message, R.id.btn_jifen, R.id.btn_tuijian, R.id.upview1, R.id.iv_art})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_search:
                break;
            case R.id.btn_sell:
                StartActivityUtils.start(getActivity(), SaleActivity.class);
                break;
            case R.id.btn_mall:
                StartActivityUtils.start(getActivity(), XiaoAoMallActivity.class);
                break;
            case R.id.btn_message:
                StartActivityUtils.start(getActivity(), NoticeActivity.class);
                break;
            case R.id.btn_jifen:
                StartActivityUtils.start(getActivity(), ScoreActivity.class);
                break;
            case R.id.btn_tuijian:
                StartActivityUtils.start(getActivity(), RecommendActivity.class);

                break;
            case R.id.upview1:
                break;
            case R.id.iv_art:
                break;
        }
    }
}
